<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."access`");
$db->exe("CREATE TABLE `".$db_prefix."access`".$db_prefix." (
  `".$db_prefix."rid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '角色ID',
  `".$db_prefix."nid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '节点ID',
  `".$db_prefix."level`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  KEY `".$db_prefix."fk_access_role1_idx`".$db_prefix." (`".$db_prefix."rid`".$db_prefix."),
  KEY `".$db_prefix."fk_access_node1_idx`".$db_prefix." (`".$db_prefix."nid`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='权限表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."address`");
$db->exe("CREATE TABLE `".$db_prefix."address`".$db_prefix." (
  `".$db_prefix."aid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `".$db_prefix."aname`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '联系人姓名',
  `".$db_prefix."amobile`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '联系电话',
  `".$db_prefix."area`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '所在地区',
  `".$db_prefix."address`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '详细地址',
  `".$db_prefix."adefault`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否为默认地址1为默认',
  `".$db_prefix."sendtime`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '派送时间',
  `".$db_prefix."postalcode`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '邮政编码',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属用户uid',
  PRIMARY KEY (`".$db_prefix."aid`".$db_prefix."),
  KEY `".$db_prefix."fk_address_user1_idx`".$db_prefix." (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COMMENT='地址表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."brand`");
$db->exe("CREATE TABLE `".$db_prefix."brand`".$db_prefix." (
  `".$db_prefix."bid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `".$db_prefix."bname`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '品牌名称',
  `".$db_prefix."blogo`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '品牌图片',
  `".$db_prefix."bsort`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '100' COMMENT '品牌排序',
  `".$db_prefix."is_hot`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否热门(1为热门)',
  PRIMARY KEY (`".$db_prefix."bid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COMMENT='品牌表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."category`");
$db->exe("CREATE TABLE `".$db_prefix."category`".$db_prefix." (
  `".$db_prefix."cid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `".$db_prefix."pid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父级ID',
  `".$db_prefix."cname`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '分类名称',
  `".$db_prefix."csort`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '100' COMMENT '排序',
  `".$db_prefix."tid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属类型ID',
  PRIMARY KEY (`".$db_prefix."cid`".$db_prefix."),
  KEY `".$db_prefix."fk_category_type_idx`".$db_prefix." (`".$db_prefix."tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=78 DEFAULT CHARSET=utf8 COMMENT='分类表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."config`");
$db->exe("CREATE TABLE `".$db_prefix."config`".$db_prefix." (
  `".$db_prefix."coid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."name`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '配置项名称',
  `".$db_prefix."value`".$db_prefix." varchar(70) NOT NULL DEFAULT '' COMMENT '配置值',
  `".$db_prefix."title`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '配置项标题',
  `".$db_prefix."des`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '配置项详细描述',
  `".$db_prefix."type_id`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '配置项类型id，相同类型id相同',
  PRIMARY KEY (`".$db_prefix."coid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=152 DEFAULT CHARSET=utf8 COMMENT='站点配置'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods`");
$db->exe("CREATE TABLE `".$db_prefix."goods`".$db_prefix." (
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
  `".$db_prefix."gname`".$db_prefix." varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称',
  `".$db_prefix."gunit`".$db_prefix." char(5) NOT NULL DEFAULT '' COMMENT '计件单位',
  `".$db_prefix."marketprice`".$db_prefix." decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '市场价',
  `".$db_prefix."shopprice`".$db_prefix." decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商场价',
  `".$db_prefix."pic`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '列表图',
  `".$db_prefix."gsum`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '总库存',
  `".$db_prefix."click`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点击数',
  `".$db_prefix."gtime`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上架时间',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属用户UID',
  `".$db_prefix."bid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属品牌BID',
  `".$db_prefix."cid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属分类CID',
  `".$db_prefix."tid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属类型TID',
  PRIMARY KEY (`".$db_prefix."gid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_user1_idx`".$db_prefix." (`".$db_prefix."uid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_brand1_idx`".$db_prefix." (`".$db_prefix."bid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_category1_idx`".$db_prefix." (`".$db_prefix."cid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_type1_idx`".$db_prefix." (`".$db_prefix."tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COMMENT='商品表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_attr`");
$db->exe("CREATE TABLE `".$db_prefix."goods_attr`".$db_prefix." (
  `".$db_prefix."gaid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
  `".$db_prefix."gvalue`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '商品属性值',
  `".$db_prefix."add`".$db_prefix." decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '附加价格',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品gid',
  `".$db_prefix."taid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属类型taid',
  PRIMARY KEY (`".$db_prefix."gaid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_attr_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_attr_type_attr1_idx`".$db_prefix." (`".$db_prefix."taid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=371 DEFAULT CHARSET=utf8 COMMENT='商品属性'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_details`");
$db->exe("CREATE TABLE `".$db_prefix."goods_details`".$db_prefix." (
  `".$db_prefix."gdid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
  `".$db_prefix."small`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '商品小图',
  `".$db_prefix."big`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '商品大图',
  `".$db_prefix."introduce`".$db_prefix." text NOT NULL COMMENT '商品详细介绍',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品gid',
  PRIMARY KEY (`".$db_prefix."gdid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_details_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COMMENT='商品详细品'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_list`");
$db->exe("CREATE TABLE `".$db_prefix."goods_list`".$db_prefix." (
  `".$db_prefix."glid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
  `".$db_prefix."combine`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '组合属性ID',
  `".$db_prefix."number`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '货号',
  `".$db_prefix."inventory`".$db_prefix." int(10) NOT NULL DEFAULT '0' COMMENT '库存',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品ID',
  PRIMARY KEY (`".$db_prefix."glid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_list_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=179 DEFAULT CHARSET=utf8 COMMENT='货品列表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."love`");
$db->exe("CREATE TABLE `".$db_prefix."love`".$db_prefix." (
  `".$db_prefix."lid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属商品ID',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属用户ID',
  PRIMARY KEY (`".$db_prefix."lid`".$db_prefix."),
  KEY `".$db_prefix."fk_love_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix."),
  KEY `".$db_prefix."fk_love_user1_idx`".$db_prefix." (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='最爱收藏表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."node`");
$db->exe("CREATE TABLE `".$db_prefix."node`".$db_prefix." (
  `".$db_prefix."nid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."name`".$db_prefix." char(45) NOT NULL DEFAULT '' COMMENT '名称',
  `".$db_prefix."pid`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '父级ID',
  `".$db_prefix."level`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '等级ID,1为模块,2为控制器,3为方法',
  `".$db_prefix."title`".$db_prefix." char(45) NOT NULL DEFAULT '',
  `".$db_prefix."state`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."dec`".$db_prefix." char(255) NOT NULL DEFAULT '',
  `".$db_prefix."sort`".$db_prefix." smallint(5) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."nid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='节点表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."order_list`");
$db->exe("CREATE TABLE `".$db_prefix."order_list`".$db_prefix." (
  `".$db_prefix."olid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."quantity`".$db_prefix." smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '购买数量',
  `".$db_prefix."subtotal`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格总计',
  `".$db_prefix."explain`".$db_prefix." text NOT NULL COMMENT '备注说明',
  `".$db_prefix."number`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '货品货号',
  `".$db_prefix."oid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属订单表ID',
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品ID',
  PRIMARY KEY (`".$db_prefix."olid`".$db_prefix."),
  KEY `".$db_prefix."fk_order_list_order1_idx`".$db_prefix." (`".$db_prefix."oid`".$db_prefix."),
  KEY `".$db_prefix."fk_order_list_goods1_idx`".$db_prefix." (`".$db_prefix."gid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=87 DEFAULT CHARSET=utf8 COMMENT='订单列表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."orderinfo`");
$db->exe("CREATE TABLE `".$db_prefix."orderinfo`".$db_prefix." (
  `".$db_prefix."oid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."onumber`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '订单号',
  `".$db_prefix."consignee`".$db_prefix." varchar(25) NOT NULL DEFAULT '' COMMENT '收货人',
  `".$db_prefix."address`".$db_prefix." varchar(60) NOT NULL DEFAULT '' COMMENT '收货地址',
  `".$db_prefix."mobile`".$db_prefix." varchar(20) NOT NULL DEFAULT '' COMMENT '手机电话',
  `".$db_prefix."total`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格总计',
  `".$db_prefix."time`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '订单时间',
  `".$db_prefix."remark`".$db_prefix." text NOT NULL COMMENT '备注说明',
  `".$db_prefix."status`".$db_prefix." enum('未付款','待发货','已发货','已完成') NOT NULL COMMENT '订单状态',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属用户ID',
  PRIMARY KEY (`".$db_prefix."oid`".$db_prefix."),
  KEY `".$db_prefix."fk_order_user1_idx`".$db_prefix." (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=81 DEFAULT CHARSET=utf8 COMMENT='订单'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."role`");
$db->exe("CREATE TABLE `".$db_prefix."role`".$db_prefix." (
  `".$db_prefix."rid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."rname`".$db_prefix." char(45) NOT NULL DEFAULT '' COMMENT '角色名称',
  `".$db_prefix."pid`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."state`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."title`".$db_prefix." char(45) NOT NULL DEFAULT '',
  PRIMARY KEY (`".$db_prefix."rid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='角色表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."type`");
$db->exe("CREATE TABLE `".$db_prefix."type`".$db_prefix." (
  `".$db_prefix."tid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `".$db_prefix."type`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '类型',
  PRIMARY KEY (`".$db_prefix."tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='类型表(衣服类型、电器类型等)'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."type_attr`");
$db->exe("CREATE TABLE `".$db_prefix."type_attr`".$db_prefix." (
  `".$db_prefix."taid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `".$db_prefix."aname`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '属性名称',
  `".$db_prefix."avalue`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '属性值',
  `".$db_prefix."atype`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '属性类型0为不可选(材质)，1为可选(尺寸,颜色,鞋号)',
  `".$db_prefix."tid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属类型ID',
  PRIMARY KEY (`".$db_prefix."taid`".$db_prefix."),
  KEY `".$db_prefix."fk_type_attr_type1_idx`".$db_prefix." (`".$db_prefix."tid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=53 DEFAULT CHARSET=utf8 COMMENT='类型属性(尺码,颜色,材质,等)'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user`".$db_prefix." (
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `".$db_prefix."username`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '用户名',
  `".$db_prefix."nickname`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '昵称',
  `".$db_prefix."password`".$db_prefix." char(32) NOT NULL DEFAULT '' COMMENT '密码',
  `".$db_prefix."realname`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '真实姓名',
  `".$db_prefix."is_admin`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否是后台用户(0为前台用户,1为后台用户)',
  `".$db_prefix."introduce`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '个人简介',
  `".$db_prefix."sex`".$db_prefix." enum('男','女') NOT NULL COMMENT '性别',
  `".$db_prefix."birthday`".$db_prefix." date NOT NULL COMMENT '生日',
  `".$db_prefix."face`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
  `".$db_prefix."regtime`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user_role`");
$db->exe("CREATE TABLE `".$db_prefix."user_role`".$db_prefix." (
  `".$db_prefix."rid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '角色ID',
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
  KEY `".$db_prefix."fk_user_role_role1_idx`".$db_prefix." (`".$db_prefix."rid`".$db_prefix."),
  KEY `".$db_prefix."fk_user_role_user1_idx`".$db_prefix." (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户角色中间表'");
